package com.faiz.picturebed.controller;

import com.faiz.picturebed.common.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(value = "redis测试API")
@RestController
@RequestMapping("redisTest")
public class RedisTestController {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @ApiOperation(value = "redis初步测试")
    @GetMapping
    public R testRedis() {
        redisTemplate.opsForValue().set("name", "faiz");
        // 从redis中获取值
        String name = (String) redisTemplate.opsForValue().get("name");

        return R.ok().data("name", name);
    }

}
